<template>
    <!-- 	<view class="tab-box">
		<view class="tabs" :class="nobg">
			<view v-for="(tab, index) in tabs" class="tab-item" :class="tabIndex==index&&'active'"
				@click="clickTab(tab,index)" :key="index">
				<text class="tab-item-text">{{tab.title}}</text>
				<view class="line"></view>
			</view>
		</view>
	</view> -->
    <view class="tab">
        <view class="tab-box">
            <view
                class="tab-item"
                v-for="(tab, index) in tabs"
                @click="clickTab(tab, index)"
                :class="{ current: tabIndex == index, 'right-current': index == 1 }"
                :key="index">
                <text>{{ tab.title }}</text>
                <view class="bg"></view>
                <view class="line" v-if="tabIndex == index"></view>
            </view>
        </view>
        <view class="tab-bg"></view>
    </view>
</template>

<script>
export default {
    props: ["tabIndex", "tabs", "nobg"],
    data() {
        return {}
    },
    methods: {
        clickTab(item, index) {
            this.$emit("clickTab", index)
        },
    },
}
</script>

<style lang="scss">
.tab {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    position: relative;
    display: flex;
    flex: 1;
    z-index: 0;
    margin: 20rpx $app-page-padding 0;

    .tab-box {
        display: flex;
        flex-direction: row;
        align-items: flex-end;
        flex: 1;
        height: 86rpx;
        perspective: 1000;
        z-index: 1;
    }

    .tab-bg {
        position: absolute;
        width: 100%;
        left: 0%;
        right: 2%;
        bottom: 0;
        z-index: 0;
        height: 82rpx;
        background: #e8ecf9;
        border-radius: 24rpx 24rpx 0 0;
        border-bottom: solid 1px #dfe3ef;
    }

    .tab-item {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 76rpx;
        min-width: 45%;
        padding-bottom: 6rpx;

        &:first-child {
            border-radius: 24rpx 0 0 0;
        }

        &:last-child {
            border-radius: 0 24rpx 0 0;
        }

        text {
            color: $app-color-text-desc;
            position: relative;
            z-index: 1;
            font-size: $font-size-30;
        }
    }

    .current {
        height: 96rpx;
        overflow: hidden;
        position: relative;
        background: rgba(0, 0, 0, 0);
        width: 150%;
        text {
            color: $app-color-main;
            font-weight: 700;
        }
        .line {
            position: absolute;
            left: 50%;
            bottom: 0;
            z-index: 0;
            border-radius: 20rpx;
            background: $app-color-main;
            width: 108rpx;
            height: 4rpx;
            margin-left: -54rpx;
        }
        .bg {
            position: absolute;
            left: 0;
            top: 0;
            z-index: 0;
            width: 86%;
            height: 96rpx;
            /* 宽高 */
            background-color: #ffffff;
            /* 颜色 */
            // padding: 4rpx 10rpx;
            border-radius: 24rpx 18rpx 0 0;
            box-shadow: 0px 0px 7px 0px rgba(185, 192, 208, 0.4);
            /* 设置圆角 */
            transform: perspective(12rpx) rotateX(1deg);
            /* 镜头距离元素表面的位置为8px，x轴为1.1倍y轴为1.3倍，绕x轴旋转5度 */
            transform-origin: 0 0;
            /* bottom left = left bottom = 0 100% 中心点偏移量*/
        }
    }
    .right-current {
        .bg {
            margin-left: 14%;
            border-radius: 18rpx 24rpx 0 0;
            // transform: perspective(5rpx) rotateX(1deg);
            /* 镜头距离元素表面的位置为8px，x轴为1.1倍y轴为1.3倍，绕x轴旋转5度 */
            transform-origin: right 0;
        }
    }
}
</style>
